

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.nn.Adam &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.nn.AdamOffload" href="mindspore.nn.AdamOffload.html" />
    <link rel="prev" title="mindspore.nn.Adagrad" href="mindspore.nn.Adagrad.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id1">基本构成单元</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id2">容器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id3">卷积层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id4">梯度</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id5">循环层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id6">稀疏层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id7">非线性激活函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id8">工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id9">图像</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id10">归一化层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id11">池化层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id12">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id13">损失函数</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.nn.html#id14">优化器</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Adagrad.html">mindspore.nn.Adagrad</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.nn.Adam</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.AdamOffload.html">mindspore.nn.AdamOffload</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.AdamWeightDecay.html">mindspore.nn.AdamWeightDecay</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.ASGD.html">mindspore.nn.ASGD</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.FTRL.html">mindspore.nn.FTRL</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Lamb.html">mindspore.nn.Lamb</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.LARS.html">mindspore.nn.LARS</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.LazyAdam.html">mindspore.nn.LazyAdam</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Momentum.html">mindspore.nn.Momentum</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Optimizer.html">mindspore.nn.Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.ProximalAdagrad.html">mindspore.nn.ProximalAdagrad</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.RMSProp.html">mindspore.nn.RMSProp</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Rprop.html">mindspore.nn.Rprop</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.SGD.html">mindspore.nn.SGD</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.thor.html">mindspore.nn.thor</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#wrapper">Wrapper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id15">数学运算</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id16">评估指标</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id17">动态学习率</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.nn.html">mindspore.nn</a> &raquo;</li>
        
      <li>mindspore.nn.Adam</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/nn/mindspore.nn.Adam.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-nn-adam">
<h1>mindspore.nn.Adam<a class="headerlink" href="#mindspore-nn-adam" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="mindspore.nn.Adam">
<em class="property">class </em><code class="sig-prename descclassname">mindspore.nn.</code><code class="sig-name descname">Adam</code><span class="sig-paren">(</span><em class="sig-param">*args</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.nn.Adam" title="Permalink to this definition">¶</a></dt>
<dd><p>Adaptive Moment Estimation (Adam)算法的实现。</p>
<p>请参阅论文 <a class="reference external" href="https://arxiv.org/abs/1412.6980">Adam: A Method for Stochastic Optimization</a>。</p>
<p>公式如下：</p>
<div class="math notranslate nohighlight">
\[\begin{split}\begin{array}{ll} \\
    m_{t+1} = \beta_1 * m_{t} + (1 - \beta_1) * g \\
    v_{t+1} = \beta_2 * v_{t} + (1 - \beta_2) * g * g \\
    l = \alpha * \frac{\sqrt{1-\beta_2^t}}{1-\beta_1^t} \\
    w_{t+1} = w_{t} - l * \frac{m_{t+1}}{\sqrt{v_{t+1}} + \epsilon}
\end{array}\end{split}\]</div>
<p><span class="math notranslate nohighlight">\(m\)</span> 代表第一个动量矩阵 <cite>moment1</cite> ，<span class="math notranslate nohighlight">\(v\)</span> 代表第二个动量矩阵 <cite>moment2</cite> ，<span class="math notranslate nohighlight">\(g\)</span> 代表 <cite>gradients</cite> ，<span class="math notranslate nohighlight">\(l\)</span> 代表缩放因子，<span class="math notranslate nohighlight">\(\beta_1,\beta_2\)</span> 代表 <cite>beta1</cite> 和 <cite>beta2</cite> ，<span class="math notranslate nohighlight">\(t\)</span> 代表当前step，<span class="math notranslate nohighlight">\(beta_1^t\)</span> 和 <span class="math notranslate nohighlight">\(beta_2^t\)</span> 代表 <cite>beta1_power</cite> 和 <cite>beta2_power</cite> ，<span class="math notranslate nohighlight">\(\alpha\)</span> 代表 <cite>learning_rate</cite> ，<span class="math notranslate nohighlight">\(w\)</span> 代表 <cite>params</cite> ，<span class="math notranslate nohighlight">\(\epsilon\)</span> 代表 <cite>eps</cite> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果前向网络使用了SparseGatherV2等算子，优化器会执行稀疏运算，通过设置 <cite>target</cite> 为CPU，可在主机（host）上进行稀疏运算。
稀疏特性在持续开发中。</p>
<p>在参数未分组时，优化器配置的 <cite>weight_decay</cite> 应用于名称不含”beta”或”gamma”的网络参数。</p>
<p>参数分组情况下，可以分组调整权重衰减策略。</p>
<p>分组时，每组网络参数均可配置 <cite>weight_decay</cite> ，若未配置，则该组网络参数使用优化器中配置的 <cite>weight_decay</cite> 。</p>
</div>
<p><strong>参数：</strong></p>
<ul>
<li><p><strong>params</strong> (Union[list[Parameter], list[dict]]) - 必须是 <cite>Parameter</cite> 组成的列表或字典组成的列表。当列表元素是字典时，字典的键可以是”params”、”lr”、”weight_decay”、”grad_centralization”和”order_params”：</p>
<ul class="simple">
<li><p><strong>params</strong> - 必填。当前组别的权重，该值必须是 <cite>Parameter</cite> 列表。</p></li>
</ul>
<ul class="simple">
<li><p><strong>lr</strong> - 可选。如果键中存在”lr”，则使用对应的值作为学习率。如果没有，则使用优化器中配置的 <cite>learning_rate</cite> 作为学习率。支持固定和动态学习率。</p></li>
</ul>
<ul class="simple">
<li><p><strong>weight_decay</strong> - 可选。如果键中存在”weight_decay”，则使用对应的值作为权重衰减值。如果没有，则使用优化器中配置的 <cite>weight_decay</cite> 作为权重衰减值。</p></li>
</ul>
<ul class="simple">
<li><p><strong>grad_centralization</strong> - 可选。如果键中存在”grad_centralization”，则使用对应的值，该值必须为布尔类型。如果没有，则认为 <cite>grad_centralization</cite> 为False。该参数仅适用于卷积层。</p></li>
</ul>
<ul class="simple">
<li><p><strong>order_params</strong> - 可选。对应值是预期的参数更新顺序。当使用参数分组功能时，通常使用该配置项保持 <cite>parameters</cite> 的顺序以提升性能。如果键中存在”order_params”，则会忽略该组配置中的其他键。”order_params”中的参数必须在某一组 <cite>params</cite> 参数中。</p></li>
</ul>
</li>
<li><p><strong>learning_rate</strong> (Union[float, Tensor, Iterable, LearningRateSchedule]): 默认值：1e-3。</p>
<ul class="simple">
<li><p><strong>float</strong> - 固定的学习率。必须大于等于零。</p></li>
<li><p><strong>int</strong> - 固定的学习率。必须大于等于零。整数类型会被转换为浮点数。</p></li>
<li><p><strong>Tensor</strong> - 可以是标量或一维向量。标量是固定的学习率。一维向量是动态的学习率，第i步将取向量中第i个值作为学习率。</p></li>
<li><p><strong>Iterable</strong> - 动态的学习率。第i步将取迭代器第i个值作为学习率。</p></li>
<li><p><strong>LearningRateSchedule</strong> - 动态的学习率。在训练过程中，优化器将使用步数（step）作为输入，调用 <cite>LearningRateSchedule</cite> 实例来计算当前学习率。</p></li>
</ul>
</li>
<li><p><strong>beta1</strong> (float) - <cite>moment1</cite> 的指数衰减率。参数范围（0.0,1.0）。默认值：0.9。</p></li>
<li><p><strong>beta2</strong> (float) - <cite>moment2</cite> 的指数衰减率。参数范围（0.0,1.0）。默认值：0.999。</p></li>
<li><p><strong>eps</strong> (float) - 将添加到分母中，以提高数值稳定性。必须大于0。默认值：1e-8。</p></li>
<li><p><strong>use_locking</strong> (bool) - 是否对参数更新加锁保护。如果为True，则 <cite>w</cite> 、<cite>m</cite> 和 <cite>v</cite> 的tensor更新将受到锁的保护。如果为False，则结果不可预测。默认值：False。</p></li>
<li><p><strong>use_nesterov</strong> (bool) - 是否使用Nesterov Accelerated Gradient (NAG)算法更新梯度。如果为True，使用NAG更新梯度。如果为False，则在不使用NAG的情况下更新梯度。默认值：False。</p></li>
<li><p><strong>weight_decay</strong> (float) - 权重衰减（L2 penalty）。必须大于等于0。默认值：0.0。</p></li>
</ul>
<ul class="simple">
<li><p><strong>loss_scale</strong> (float) - 梯度缩放系数，必须大于0。如果 <cite>loss_scale</cite> 是整数，它将被转换为浮点数。通常使用默认值，仅当训练时使用了 <cite>FixedLossScaleManager</cite>，且 <cite>FixedLossScaleManager</cite> 的 <cite>drop_overflow_update</cite> 属性配置为False时，此值需要与 <cite>FixedLossScaleManager</cite> 中的 <cite>loss_scale</cite> 相同。有关更多详细信息，请参阅 <a class="reference internal" href="../mindspore/mindspore.FixedLossScaleManager.html#mindspore.FixedLossScaleManager" title="mindspore.FixedLossScaleManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">mindspore.FixedLossScaleManager</span></code></a>。默认值：1.0。</p></li>
</ul>
<p><strong>输入：</strong></p>
<ul class="simple">
<li><p><strong>gradients</strong> (tuple[Tensor]) - <cite>params</cite> 的梯度，形状（shape）与 <cite>params</cite> 相同。</p></li>
</ul>
<p><strong>输出：</strong></p>
<p>Tensor[bool]，值为True。</p>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - <cite>learning_rate</cite> 不是int、float、Tensor、Iterable或LearningRateSchedule。</p></li>
<li><p><strong>TypeError</strong> - <cite>parameters</cite> 的元素不是Parameter或字典。</p></li>
<li><p><strong>TypeError</strong> - <cite>beta1</cite> 、<cite>beta2</cite> 、 <cite>eps</cite> 或 <cite>loss_scale</cite> 不是float。</p></li>
<li><p><strong>TypeError</strong> - <cite>weight_decay</cite> 不是float或int。</p></li>
<li><p><strong>TypeError</strong> - <cite>use_locking</cite> 或 <cite>use_nesterov</cite> 不是bool。</p></li>
<li><p><strong>ValueError</strong> - <cite>loss_scale</cite> 或 <cite>eps</cite> 小于或等于0。</p></li>
<li><p><strong>ValueError</strong> - <cite>beta1</cite> 、<cite>beta2</cite> 不在（0.0,1.0）范围内。</p></li>
<li><p><strong>ValueError</strong> - <cite>weight_decay</cite> 小于0。</p></li>
</ul>
<p><strong>支持平台：</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">Ascend</span></code> <code class="docutils literal notranslate"><span class="pre">GPU</span></code>  <code class="docutils literal notranslate"><span class="pre">CPU</span></code></p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore</span> <span class="kn">import</span> <span class="n">nn</span><span class="p">,</span> <span class="n">Model</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">net</span> <span class="o">=</span> <span class="n">Net</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#1) All parameters use the same learning rate and weight decay</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">optim</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">Adam</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="n">net</span><span class="o">.</span><span class="n">trainable_params</span><span class="p">())</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#2) Use parameter groups and set different values</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">conv_params</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">filter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s1">&#39;conv&#39;</span> <span class="ow">in</span> <span class="n">x</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">net</span><span class="o">.</span><span class="n">trainable_params</span><span class="p">()))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">no_conv_params</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">filter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s1">&#39;conv&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">x</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">net</span><span class="o">.</span><span class="n">trainable_params</span><span class="p">()))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">group_params</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">&#39;params&#39;</span><span class="p">:</span> <span class="n">conv_params</span><span class="p">,</span> <span class="s1">&#39;weight_decay&#39;</span><span class="p">:</span> <span class="mf">0.01</span><span class="p">,</span> <span class="s1">&#39;grad_centralization&#39;</span><span class="p">:</span><span class="kc">True</span><span class="p">},</span>
<span class="gp">... </span>                <span class="p">{</span><span class="s1">&#39;params&#39;</span><span class="p">:</span> <span class="n">no_conv_params</span><span class="p">,</span> <span class="s1">&#39;lr&#39;</span><span class="p">:</span> <span class="mf">0.01</span><span class="p">},</span>
<span class="gp">... </span>                <span class="p">{</span><span class="s1">&#39;order_params&#39;</span><span class="p">:</span> <span class="n">net</span><span class="o">.</span><span class="n">trainable_params</span><span class="p">()}]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">optim</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">Adam</span><span class="p">(</span><span class="n">group_params</span><span class="p">,</span> <span class="n">learning_rate</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">weight_decay</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># The conv_params&#39;s parameters will use default learning rate of 0.1 and weight decay of 0.01 and grad</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># centralization of True.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># The no_conv_params&#39;s parameters will use learning rate of 0.01 and default weight decay of 0.0 and grad</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># centralization of False.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># The final parameters order in which the optimizer will be followed is the value of &#39;order_params&#39;.</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">loss</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">SoftmaxCrossEntropyWithLogits</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">model</span> <span class="o">=</span> <span class="n">Model</span><span class="p">(</span><span class="n">net</span><span class="p">,</span> <span class="n">loss_fn</span><span class="o">=</span><span class="n">loss</span><span class="p">,</span> <span class="n">optimizer</span><span class="o">=</span><span class="n">optim</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt id="mindspore.nn.Adam.target">
<em class="property">property </em><code class="sig-name descname">target</code><a class="headerlink" href="#mindspore.nn.Adam.target" title="Permalink to this definition">¶</a></dt>
<dd><p>该属性用于指定在主机（host）上还是设备（device）上更新参数。输入类型为str，只能是’CPU’，’Ascend’或’GPU’。</p>
</dd></dl>

</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.nn.AdamOffload.html" class="btn btn-neutral float-right" title="mindspore.nn.AdamOffload" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.nn.Adagrad.html" class="btn btn-neutral float-left" title="mindspore.nn.Adagrad" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>